<?php
class GradeAction extends Action{

    public function grade(){
        $this->display();
    }

    public function doSearch(){

        $grade=$this->_param('grade');
        $term=$this->_param('term');
        $subject=$this->_param('subject');
        $Blog = D("SearchView");

        if(($grade) == "所有" ){
            if($term == "所有"){
                if($subject == "所有"){
                    $where='';
                }else{
                    $where['Score.subject']=$subject;
                }
            }else{
                if($subject == "所有"){
                    $where['Score.term']=$term;
                }else{
                    $where['Score.subject']=$subject;
                    $where['Score.term']=$term;
                }
            }
        }else{
            if($term == "所有"){
                if($subject == "所有"){
                    $where['Score.grade']=$grade;
                }else{
                    $where['Score.grade']=$grade;
                    $where['Score.subject']=$subject;
                }
            }else{
                if($subject == "所有"){
                    $where['Score.grade']=$grade;
                    $where['Score.term']=$term;
                }else{
                    $where['Score.term']=$term;
                    $where['Score.grade']=$grade;
                    $where['Score.subject']=$subject;
                }
            }
        }

        $arr=$Blog->where($where)->order('grade ,term ,subject,stu_id')->page($_GET['p'].',20')->select();

        import("ORG.Util.Page");
        
        $count = $Blog->where($where)->count();
        $Page = new Page($count,20);//实例化分页类传入总记录数和每页显示的记录

        $show = $Page->show();//分页显示输出
        $this->assign('page',$show);


        $this->assign('data',$arr);
        $this->display();
    }

}
?>